#ifndef LASERCAMERATRAJSERVER_H
#define LASERCAMERATRAJSERVER_H

#include "mccontrollerthread.h"
#include <QQueue>
#include <QMutex>
class TrajOrientationCalculate;

class LaserCameraTrajServer
{
public:
    LaserCameraTrajServer(QString configFileIn,int robotIdIn,McControllerThread *programMcControllerIn);

    int startBuffer();
    int stopBuffer();
    int getTraj(QVector<PointPro> refOri, QVector<PointPro> &keyPointsOut);
    int getLaserCameraBufferMoveConfigParameter(struct BufferMoveConfig &paraOut);
    int writeConfigFile(BufferMoveConfig bufferMoveConfigIn);

private:
    int loopOnce();
    void* threadRun(void *);
    static void* threadTask( void* classPtr );
    void createThread();

    int writeDataQueueToFile(QQueue<Pinfo> &bufferPointQueueIn,QString newFileName);

    int writeConfigFile(QString configFileName,BufferMoveConfig bufferMoveConfigIn);
    int initialConfigFile(QString configFileName);

    void addMsg( int messageLevel,
                 std::string componentName,
                 std::string messageType,
                 int messageCode,
                 int robotId,
                 int parameter1 = 0,
                 int parameter2 = 0,
                 int parameter3 = 0,
                 int parameter4 = 0,
                 QString message= "");

private:
    int robotId;
    bool isInitialed;
    bool isStart;
    McControllerThread *programMcController;
    QQueue<Pinfo> bufferPointQueue;
    QMutex usingMutex;

    TrajOrientationCalculate *trajOrientationCal;
    BufferMoveConfig bufferMoveConfig;
    QString configFile;
};

#endif // LASERCAMERATRAJSERVER_H
